# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import scrapy


class DoubanItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    abstract = scrapy.Field()
    title = scrapy.Field()
    update_time = scrapy.Field()
    read_count = scrapy.Field()
    likers_count = scrapy.Field()
    timeline_share_count = scrapy.Field()
    comments_count = scrapy.Field()
    db_type = scrapy.Field()
    author_uid = scrapy.Field()
    author_name = scrapy.Field()
    author_url = scrapy.Field()
    topic_name = scrapy.Field()
    def save_to_mysql(self):
        sql = 'insert into db_info(abstract,title,update_time,read_count,likers_count,timeline_share_count,comments_count,db_type,author_uid,author_name,author_url,topic_name)' \
              'values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'\

        data = (self["abstract"],self["title"],self["update_time"],self["read_count"],self["likers_count"],self["timeline_share_count"],self["comments_count"],self["db_type"],self["author_uid"],self["author_name"],self["author_url"],self["topic_name"])

        return sql,data